<?php

declare (strict_types=1);
namespace App\Model;

use App\Constants\Constant;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $pay_id 
 * @property int $user_id 
 * @property int $origin 
 * @property int $source_id 
 * @property float $total_fee
 * @property float $cash_fee
 * @property int $score 
 * @property string $platform_trade_no 
 * @property string $channel_trade_no
 * @property string $platform_refund_no 
 * @property string $channel_refund_no
 * @property int $pay_status 
 * @property int $order_status 
 * @property string $attach 
 * @property string $add_time 
 */
class Payment extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'payment';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['pay_id' => 'integer', 'user_id' => 'integer', 'origin' => 'integer', 'source_id' => 'integer', 'total_price' => 'float', 'cash_price' => 'float', 'score' => 'integer', 'pay_status' => 'integer', 'order_status' => 'integer','attach'=>'json'];

    public $timestamps = false;

    protected $primaryKey = "pay_id";

    //防止中文乱码
    protected function asJson($value)
    {
        return json_encode($value,JSON_UNESCAPED_UNICODE);
    }

    public function user(){
        return $this->hasOne(User::class,"user_id","user_id");
    }

    public function activity(){
        return $this->hasOne(Activity::class,"act_id","source_id");
    }
}